package com.activiti.spring.controller;

import java.util.List;

import org.activiti.engine.HistoryService;
import org.activiti.engine.history.HistoricProcessInstance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HistoryActivitiController {
	@Autowired
	private HistoryService historyService;
	
	
	@GetMapping("historyList")
	@ResponseBody
	public String historyList(@RequestParam("processDefinitionId") String processDefinitionId){
		List<HistoricProcessInstance> hpi=historyService.createHistoricProcessInstanceQuery()
		.processDefinitionId(processDefinitionId)
		.list();
		for(HistoricProcessInstance hi:hpi){
			System.out.println(hi.getId());
			System.out.println(hi.getProcessDefinitionId());
			System.out.println(hi.getStartTime());
			System.out.println(hi.getEndTime());
			System.out.println(hi.getDeploymentId());
			System.out.println("+====================");
		}
		return "";
	}

}
